{% extends 'classroom-manage/students.html.twig' %}
{% block title %}{{'classroom.student_manage'|trans}} - {{ parent() }}{% endblock %}
{% set submenu = 'student' %}
{% do script(['libs/bootstrap-datetimepicker.js', 'app/js/classroom-manage/students-manage/index.js']) %}

{% block maincontent %}

  <form class="form-inline well well-sm class-student-filter-form" action="" method="get" novalidate>
    <div class="form-group col-md-10">
      <input data-role="search-conditions" class="form-control" style="width:33%" type="text" placeholder="{{'classroom.student_placeholder'|trans}}" name="keyword" value="{{ app.request.get('keyword') }}">
      <select data-role="search-conditions" class="form-control" name="expired">
        {% set options = {'in':'classroom.student_study_expiry_date.in'|trans,'out':'classroom.student_study_expiry_date.not'|trans} %}
        {{ select_options(options, app.request.get('expired'), 'classroom.student_study_expiry_date'|trans) }}
      </select>
      <a class="btn btn-primary js-search-btn">{{'form.btn.search'|trans}}</a>
      {% if disableDeleteSearchResult %}
        <button class="btn btn-primary {% if students|length <= 0 %}hidden{% endif %}" disabled="disabled">{{ 'classroom.delete_condition_student'|trans }}</button>
      {% else %}
        <a class="btn btn-primary js-delete-all {% if students|length <= 0 %}hidden{% endif %}" data-url="{{ path('classroom_manage_student_batch_remove_all', {id: classroom.id}) }}">{{ 'classroom.delete_condition_student'|trans }}</a>
      {% endif %}
    </div>
    <div class="clearfix"></div>
  </form>

  {% if students|length > 0 %}
      <button id="batch-update-expiry-day" type="button" class="cd-btn cd-btn-primary cd-mb16" data-url="{{ path('classroom_manage_member_deadline', {classroomId: classroom.id}) }}">{{ 'classroom.student_batch_update_expiry_date'|trans }}</button>
    <button id="batch-remove" type="button" class="cd-btn cd-btn-primary cd-mb16" data-url="{{ path('classroom_manage_student_batch_remove', {id: classroom.id}) }}">{{ 'classroom.student_batch_remove'|trans }}</button>
  {% endif %}

  <table class="table table-striped" id="course-student-list">
    <thead>
      <tr>
        <th><input type="checkbox" autocomplete="off" data-role="batch-select"></th>
        <th width="30%">{{'classroom.student_name'|trans}}</th>
        <th width="20%">{{'classroom.student_study_status'|trans}}</th>
        <th width="20%">{{'classroom.student_study_expiry_date'|trans}}</th>
        <th width="30%">{{'classroom.student_opertion'|trans}}</th>
      </tr>
    </thead>
    <tbody>
      {% for student in students %}
        {% set user = users[student.userId] %}
        {% include ('classroom-manage/tr.html.twig') %}
      {% else %}
        <tr class="empty"><td colspan="20">{{'classroom.student_empty'|trans}}</td></tr>
      {% endfor %}
    </tbody>
  </table>

  {{ web_macro.paginator(paginator) }}

{% endblock %}